package org.xdq.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.xdq.dto.RoleDto;
import org.xdq.model.Module;
import org.xdq.model.Role;


public interface RoleDao {

	//@Select("select * from sys_role")
	List<Role> findRoleList(RoleDto dto);

	@Select("select ifnull(max(ro_id),0) from sys_role")
	int findMaxId();

	@Insert("insert into sys_role(ro_id,ro_name,ro_remark,ro_status) values(#{ro_id},#{ro_name},#{ro_remark},'00')")
	void insertOneRole(RoleDto dto);

	@Update("update sys_role set ro_name = #{ro_name} , ro_remark = #{ro_remark} where ro_id = #{ro_id}")
	void updateOneRole(RoleDto dto);

	void deleteRoles(@Param("ids") Integer... id);

	void changeRoleStatus(@Param("srcStatus") String srcStatus, @Param("targetStatus")String targetStatus, @Param("id")Integer... id);

	@Select("select m_id,m_name from sys_module where m_pid is not null and m_ismenu = 1")
	List<Module> findAllModuleList();

	@Select("select rm.m_id from sys_rm rm join sys_module m on rm.m_id = m.m_id where ro_id =#{ro_id} and m.m_status = '55' and m.m_ismenu = 1")
	List<Integer> findRoleModuleId(Integer ro_id);
	
	@Delete("delete from sys_rm where ro_id = #{ro_id}")
	void deleteRoleModule(Integer ro_id);

	void insertRoleModule(@Param("ro_id") Integer ro_id, @Param("m_ids") Integer[] m_ids);

	

}
